package node

import "fmt"
import corev1 "k8s.io/api/core/v1"

type v1_node struct {
	node_name   string
	node_status string
}

func new_node(spec, status string) *v1_node {
	v1Node := v1_node{
		node_name:   spec,
		node_status: status,
	}
	return &v1Node
}

func Show(k8s_node *corev1.NodeList) []v1_node {
	var nodes []v1_node = make([]v1_node, 0)
	for _, node := range k8s_node.Items {
		name := node.Name
		kubelet_status := node.Status.Conditions[4].Type
		unschedulable := node.Spec.Unschedulable
		if unschedulable {
			kubelet_status += "\t unschedulable"
		} else {
			kubelet_status += "\t schedulable"
		}

		v1Node := new_node(name, string(kubelet_status))
		nodes = append(nodes, *v1Node)
	}
	fmt.Printf("node info\n")
	for _, node := range nodes {
		fmt.Printf("node:%s\tnode_status:%s\n", node.node_name, node.node_status)
	}
	fmt.Printf("\n")

	return nodes
}
